/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.scrumpmt.domain;

import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author agumpg
 */
@Entity
@Table(name = "PROYECTO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Proyecto.findAll", query = "SELECT p FROM Proyecto p"),
    @NamedQuery(name = "Proyecto.findAllActivos", query = "SELECT p FROM Proyecto p WHERE p.activo = :activo"),
    @NamedQuery(name = "Proyecto.findById", query = "SELECT p FROM Proyecto p WHERE p.id = :id"),
    @NamedQuery(name = "Proyecto.findByNombre", query = "SELECT p FROM Proyecto p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Proyecto.findByDes", query = "SELECT p FROM Proyecto p WHERE p.des = :des"),
    @NamedQuery(name = "Proyecto.findByNomcli", query = "SELECT p FROM Proyecto p WHERE p.nomcli = :nomcli"),
    @NamedQuery(name = "Proyecto.findByFecini", query = "SELECT p FROM Proyecto p WHERE p.fecini = :fecini"),
    @NamedQuery(name = "Proyecto.findByFecfin", query = "SELECT p FROM Proyecto p WHERE p.fecfin = :fecfin"),
    @NamedQuery(name = "Proyecto.findByHorasJornada", query = "SELECT p FROM Proyecto p WHERE p.horasJornada = :horasJornada")})
public class Proyecto extends BaseEntity {
    @Column(name = "nombre", nullable=false)
    private String nombre;
    @Column(name = "des", nullable=false)
    private String des;
    @Column(name = "nomcli", nullable=false)
    private String nomcli;
    @Column(name = "fecini", nullable=false)
    @Temporal(TemporalType.DATE)
    private Date fecini;
    @Column(name = "fecfin", nullable=true)
    @Temporal(TemporalType.DATE)
    private Date fecfin;
    @Column(name = "horas_jornada", nullable=false)
    private Integer horasJornada;   
    @Column(name = "activo", nullable=false)
    private Integer activo;
    @ManyToMany(mappedBy = "proyectoCollection")
    private Collection<Colaborador> colaboradorCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProyectoFk")
    private Collection<Sprint> sprintCollection;
    @OneToMany(fetch= FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "idProyectoFk")
    private Collection<Tarea> tareaCollection;
    @JoinColumn(name = "id_scrum_master", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Colaborador idScrumMaster;

    public Proyecto() {
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des;
    }

    public String getNomcli() {
        return nomcli;
    }

    public void setNomcli(String nomcli) {
        this.nomcli = nomcli;
    }

    public Date getFecini() {
        return fecini;
    }

    public void setFecini(Date fecini) {
        this.fecini = fecini;
    }

    public Date getFecfin() {
        return fecfin;
    }

    public void setFecfin(Date fecfin) {
        this.fecfin = fecfin;
    }

    public Integer getHorasJornada() {
        return horasJornada;
    }

    public void setHorasJornada(Integer horasJornada) {
        this.horasJornada = horasJornada;
    }

    public Integer getActivo() {
        return activo;
    }

    public void setActivo(Integer activo) {
        this.activo = activo;
    }

    @XmlTransient
    public Collection<Colaborador> getColaboradorCollection() {
        return colaboradorCollection;
    }

    public void setColaboradorCollection(Collection<Colaborador> colaboradorCollection) {
        this.colaboradorCollection = colaboradorCollection;
    }

    @XmlTransient
    public Collection<Sprint> getSprintCollection() {
        return sprintCollection;
    }

    public void setSprintCollection(Collection<Sprint> sprintCollection) {
        this.sprintCollection = sprintCollection;
    }

    //@XmlTransient
    public Collection<Tarea> getTareaCollection() {
        return tareaCollection;
    }

    public void setTareaCollection(Collection<Tarea> tareaCollection) {
        this.tareaCollection = tareaCollection;
    }

    public Colaborador getIdScrumMaster() {
        return idScrumMaster;
    }

    public void setIdScrumMaster(Colaborador idScrumMaster) {
        this.idScrumMaster = idScrumMaster;
    }
       
}
